<?php
if (!function_exists('borrowStatus')) {
    /**
     * 标的状态
     */
    function borrowStatus($borrow = array(), $isCanSet = true) {

        //标的结束时间
        $endTime = $borrow['verify_time']+$borrow['valid_time'] * 3600 * 24;

        if((strtotime($borrow['open_time'])>time()) && $borrow['fstatus'] == 1){
            return '<span class="tz_index_invest">即将开放</span>';
        }
        //可投标
        if ($borrow['account_yes'] < $borrow['account'] && in_array($borrow['fstatus'], array(1, 3)) && time() <= $endTime) {
            return '<span class="tz_index_invest">抢购中</span>';
        }
        //还款逾期
        if ($borrow['repayment_account'] != $borrow['repayment_yesaccount'] && $borrow['end_time'] < time() && $borrow['fstatus'] == 3) {
            return '<span class="tz_index_invest">还款逾期</span>';
        }
        //还款中
        if ($borrow['account_yes'] >= $borrow['account'] && $borrow['fstatus'] == 3 && $borrow['repayment_yesaccount'] < $borrow['repayment_account']){
            return '<span class="tz_index_invest" >还款中</span>';
        }

        //已完成
        if ($borrow['account_yes'] ==  $borrow['account'] && $borrow['fstatus']==3 && $borrow['repayment_yesaccount'] == $borrow['repayment_account']) {
            return '<span class="tz_index_invest">已完成</span>';
        }

        //已过期
        if ($endTime < time()){
            return '<span class="tz_index_invest">已过期</span>';
        }

        return '<span class="tz_index_invest">已满标</span>';
    }
}

if (!function_exists('borrowStatus2')) {
    /**
     * 标的状态
     */
    function borrowStatus2($borrow = array(), $isCanSet = true) {

        //标的结束时间
        $endTime = strtotime($borrow['valid_time'] . ($borrow['is_day'] == 1 ? 'days' : 'month'), $borrow['verify_time']);

        if((strtotime($borrow['open_time'])>time()) && $borrow['fstatus'] == 1){
            return '<span class="tz_index_invest">即将开放</span>';
        }
        //可投标
        if ($borrow['account_yes'] < $borrow['account'] && in_array($borrow['fstatus'], array(1, 3)) && time() <= $endTime) {
            return '<span class="tz_index_invest">立刻投资</span>';
        }
        //还款逾期
        if ($borrow['repayment_account'] != $borrow['repayment_yesaccount'] && $borrow['end_time'] < time() && $borrow['fstatus'] == 3) {
            return '<span class="tz_index_invest">还款逾期</span>';
        }
        //还款中
        if ($borrow['account_yes'] >= $borrow['account'] && $borrow['fstatus'] == 3 && $borrow['repayment_yesaccount'] < $borrow['repayment_account']){
            return '<span class="tz_index_invest" >还款中</span>';
        }
        //已过期
        if ($endTime < time()){
            return '<span class="tz_index_invest">已过期</span>';
        }

        if ($borrow['account_yes'] ==  $borrow['account'] && $borrow['fstatus']==3 && time() <= $endTime) {
            return '<span class="tz_index_invest">已完成</span>';
        }

        return '<span class="tz_index_invest">投资已满</span>';
    }
}

?>